home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Draw / Sources / DrawPart.h < prev    next >
Encoding:
Text File  |  1996-12-16  |  13.9 KB  |  435 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawPart.h
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef DRAWPART_H
  13. #define DRAWPART_H
  14.  
  15. #ifndef FWPARTNG_H
  16. #include "FWPartng.h"
  17. #endif
  18.  
  19. #ifndef FWSELECT_H
  20. #include "FWSelect.h"
  21. #endif
  22.  
  23. #ifndef FWPRTSCP_H
  24. #include "FWPrtScp.h"
  25. #endif
  26.  
  27. #ifndef FWPAT_H
  28. #include "FWPat.h"
  29. #endif
  30.  
  31. #ifndef FWCOLOR_H
  32. #include "FWColor.h"
  33. #endif
  34.  
  35. #ifndef FWPOINT_H
  36. #include "FWPoint.h"
  37. #endif
  38.  
  39. #ifndef FWRESFIL_H
  40. #include "FWResFil.h"
  41. #endif
  42.  
  43. #ifndef FWRECEVR_H
  44. #include "FWRecevr.h"
  45. #endif
  46.  
  47. #ifndef FWNOTIFR_H
  48. #include "FWNotifr.h"
  49. #endif
  50.  
  51. //========================================================================================
  52. //    Forward Declarations
  53. //========================================================================================
  54.  
  55. class FW_CFloatingWindow;
  56. class FW_CMenuEvent;
  57. class FW_CDropCommand;
  58. class FW_CPresentation;
  59.  
  60. class CBaseShape;
  61. class CProxyShape;
  62. class CToolFrame;
  63. class CPaletteFrame;
  64. class CPatternFrame;
  65. class CDrawSelection;
  66. class FW_CGraphicContext;
  67. class CDrawLinkManager;
  68. class CDrawPartContent;
  69. class CDrawFrame;
  70.  
  71. //========================================================================================
  72. //    Defines
  73. //========================================================================================
  74.  
  75. #define kContentAnnotationProp        "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:ODFExamples:Annotation:Property:ODFDraw"
  76. #define kContentAnnotationValue        "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:ODFExamples:Annotation:Value:ODFDraw"
  77.  
  78. //========================================================================================
  79. //    class CDrawPart
  80. //========================================================================================
  81.  
  82. class CDrawPart : public FW_CEmbeddingPart, public FW_MEmbeddingPartScriptable, public FW_MReceiver, public FW_MNotifier
  83. {
  84. public:
  85.     FW_DECLARE_CLASS
  86.     FW_DECLARE_AUTO(CDrawPart)
  87.     
  88.     friend class CDrawLinkManager;
  89.  
  90. //----------------------------------------------------------------------------------------
  91. //    Initialization/Destruction
  92. //
  93. public:        
  94.     CDrawPart(ODPart* odPart);
  95.     virtual ~ CDrawPart();
  96.  
  97.     virtual void                ReleaseAll(Environment *ev);
  98.     virtual void                Initialize(Environment *ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage);
  99.         
  100.     void                        InitializePalettes(Environment *ev);
  101.     
  102. //----------------------------------------------------------------------------------------
  103. //    Inherited API
  104. //
  105. public:
  106.     virtual void                EmbeddedFrameRemoved(Environment *ev, 
  107.                                     FW_MProxy* proxy);
  108.     
  109.     virtual FW_Handled            DoMenu(Environment *ev, 
  110.                                     const FW_CMenuEvent& theMenuEvent);
  111.     virtual FW_Handled            DoAdjustMenus(Environment *ev, 
  112.                                     FW_CMenuBar* menuBar, 
  113.                                     FW_Boolean hasMenuFocus, FW_Boolean isRoot);
  114.     
  115.     virtual FW_Handled            DoAbout(Environment* ev);
  116.  
  117.     virtual FW_CFrame*             NewFrame(Environment *ev,
  118.                                     ODFrame* odFrame, 
  119.                                     FW_CPresentation* presentation,
  120.                                     FW_Boolean fromStorage);
  121.                                     
  122.     virtual FW_CLinkManager*     NewLinkManager(Environment *ev);
  123.     
  124.     virtual FW_CContent*        NewPartContent(Environment* ev);
  125.  
  126.     virtual FW_CWindow*            NewDocumentWindow(Environment* ev);
  127.     
  128.     virtual void                HandleNotification(Environment* ev, const FW_CNotification& notification);
  129.  
  130.     virtual FW_Boolean            InternalizeContent(Environment* ev, 
  131.                                                 ODStorageUnit* storageUnit, 
  132.                                                 FW_CCloneInfo* cloneInfo);
  133.  
  134.     virtual void                ExternalizeContent(Environment* ev, 
  135.                                                 ODStorageUnit* storageUnit, 
  136.                                                 FW_CCloneInfo* cloneInfo);
  137.  
  138.     virtual void                PrintInfoChanged(Environment *ev, FW_CPrintInfo* printInfo);
  139.     
  140.     virtual void                FocusAcquiredInFrame(Environment* ev, 
  141.                                                 ODTypeToken focus, 
  142.                                                 FW_CFrame* frame);
  143.     virtual void                FocusLostInFrame(Environment* ev, 
  144.                                                 ODTypeToken focus, 
  145.                                                 FW_CFrame* frame,   
  146.                                                 FW_Boolean samePart);
  147.  
  148. //----------------------------------------------------------------------------------------
  149.   private:
  150.     void                        InstallCustomEditMenu(Environment* ev);
  151.     void                        UninstallCustomEditMenu(Environment* ev);
  152.     
  153. //----------------------------------------------------------------------------------------
  154. //    New API
  155. //
  156. public:    
  157.     void                        RemoveShapeFromPart(Environment* ev, CBaseShape* shape);
  158.     void                        AddShapeToPart(Environment* ev, CBaseShape* shape);
  159.  
  160.     CBaseShape*                 WhichShape(Environment *ev, 
  161.                                         FW_CGraphicContext& gc,
  162.                                         const FW_CMouseEvent& theMouseEvent,
  163.                                         FW_Boolean hasToBeSelected) const;
  164.  
  165.     FW_Fixed                    GetPenSize() const;
  166.     unsigned short                GetRenderVerb() const;
  167.  
  168.     FW_CPoint                    GetDrawingSize() const;
  169.     void                        SetDrawingSize(Environment* ev, const FW_CPoint& newSize);
  170.     
  171.     void                        CheckTool(Environment* ev, unsigned short oldTool, unsigned short newTool);
  172.     void                        CheckRenderVerb(Environment* ev, unsigned short oldRenderVerb, unsigned short newRenderVerb);
  173.     void                        SetRenderVerb(Environment* ev, unsigned short renderVerb);
  174.     
  175.     void                        GetFillColor(FW_CColor& color) const;
  176.     void                        GetFrameColor(FW_CColor& color) const;
  177.     
  178.     void                        SetColor(Environment* ev, const FW_CColor& color, FW_ERenderVerbs renderVerb);
  179.     
  180.     FW_CPattern                    GetFillPattern() const;
  181.     FW_CPattern                    GetFramePattern() const;
  182.  
  183.     void                        SetPattern(Environment* ev, short newFillPatIndex, FW_ERenderVerbs renderVerb);
  184.     
  185.     void                        UpdateAfterMove(Environment* ev);
  186.  
  187.     void                        SetTool(Environment* ev, unsigned short newTool);
  188.     unsigned short                GetTool() const;
  189.                                 
  190.     FW_CPattern                    GetPattern(short patIndex) const;
  191.     
  192.     void                         NotifyForColorChanged(Environment *ev, const FW_CColor& color, FW_ERenderVerbs renderVerb);
  193.     void                         NotifyForPatternChanged(Environment *ev, short patIndex, FW_ERenderVerbs renderVerb);
  194.  
  195.     FW_CPresentation*            GetMainPresentation() const;
  196.     FW_CPresentation*            GetPalettePresentation() const;
  197.     FW_CPresentation*            GetPatternPresentation() const;
  198.     FW_CPresentation*            GetToolPresentation() const;
  199.     FW_CPresentation*             GetPrintPresentation() const;
  200.     
  201.     FW_Boolean                    UseRoundEnds() const
  202.                                         {return fRoundEnds;}
  203.     void                        ChangeRoundEnds(FW_Boolean state)
  204.                                         {fRoundEnds = state;}
  205.                                         
  206.     FW_Fixed                    GetRoundRectRadius() const
  207.                                         {return fRoundRectRadius;}
  208.     void                        ChangeRoundRectRadius(FW_Fixed radius)
  209.                                         {fRoundRectRadius = radius;}
  210.     
  211.     FW_Boolean                    IsAutoGridOn() const;
  212.     
  213.     CDrawPartContent*            GetDrawContent() const;
  214.     
  215.     void                        SetDocumentDimensions(Environment *ev, unsigned char hPages, unsigned char vPages);
  216.     void                        GetDocumentDimensions(Environment *ev, unsigned char& hPages, unsigned char& vPages);
  217.     
  218.     FW_CPoint                    GetPageSize() const;
  219.     
  220.     void                        OpenRoundCornersDialog(Environment* ev);
  221.  
  222.     //--- Persistent link support ---
  223.     void                        DoPostCreate(Environment* ev);    // MacApp forever!
  224.     CBaseShape*                    FindShapeWithIndex(short extIndex);
  225.  
  226.     //--- Semantic Object ---
  227.     
  228.     virtual FW_CElementIterator*    NewElementIterator(Environment* ev,
  229.                                                         FW_CPart* part,
  230.                                                         ODDescType desiredClass) const;
  231.  
  232.     virtual void                    DoAECreateElement(Environment* ev,
  233.                                                         FW_CPart* part,
  234.                                                         const FW_CAppleEvent& event,
  235.                                                         FW_CAppleEvent& reply);
  236.     
  237.     FW_Boolean                        ShapeClassToType(ODDescType shapeClass,
  238.                                                     unsigned short& shapeType) const;
  239.  
  240. //----------------------------------------------------------------------------------------
  241. //    Data Members
  242. //
  243. private:    
  244.     short                fNbEmbedded;
  245.     unsigned char        fHorizPages;
  246.     unsigned char        fVertPages;
  247.     FW_CPoint            fPageSize;
  248.     
  249.     FW_CFloatingWindow*    fPaletteWindow;
  250.     FW_CFloatingWindow*    fPatternWindow;
  251.     FW_CFloatingWindow*    fToolsWindow;
  252.  
  253.     CToolFrame*            fToolFrame;
  254.     CPaletteFrame*        fPaletteFrame;
  255.     CPatternFrame*        fPatternFrame;
  256.         
  257.     CDrawPartContent*    fPartContent;
  258.     FW_CPoint            fDrawingSize;
  259.     
  260.     unsigned short        fTool;
  261.     FW_Fixed            fCurrentPenSize;
  262.     unsigned short        fRenderVerb;
  263.     FW_CColor            fFillColor;
  264.     FW_CColor            fFrameColor;
  265.     short                fFillPatIndex;
  266.     short                fFramePatIndex;
  267.     FW_Fixed            fRoundRectRadius;
  268.     FW_Boolean            fRoundEnds;
  269.     
  270.     CDrawSelection*        fDrawSelection;    // Attention I don't own the selection the presentation is
  271.     
  272.     FW_CPresentation*    fPalettePresentation;
  273.     FW_CPresentation*    fPatternPresentation;
  274.     FW_CPresentation*    fToolPresentation;
  275.     FW_CPresentation*    fMainPresentation;
  276.     FW_CPresentation*    fAlignObjectsPresentation;
  277.     FW_CPresentation*    fPrintPresentation;
  278.     FW_CPresentation*    fRoundCornersPresentation;
  279.     
  280.     FW_CPattern            fPatternTable[12];
  281.     
  282.     FW_Boolean            fAutoGrid;
  283.  
  284.     ODCommandID            fUnit;
  285.     ODCommandID            fArcUnit;
  286.  
  287.     FW_Boolean            fPostCreated;    // perform DoPostCreate only once
  288.     FW_Boolean            fHasMenuFocus;
  289.     short                fEditMenuID;
  290.     short                fEditMenuPosition;
  291. };
  292.  
  293. //========================================================================================
  294. //    Inlines
  295. //========================================================================================
  296.  
  297. //----------------------------------------------------------------------------------------
  298. //    CDrawPart::GetDrawContent
  299. //----------------------------------------------------------------------------------------
  300. inline CDrawPartContent* CDrawPart::GetDrawContent() const
  301. {
  302.     return fPartContent;
  303. }
  304.  
  305. //----------------------------------------------------------------------------------------
  306. //    CDrawPart::GetDrawingSize
  307. //----------------------------------------------------------------------------------------
  308. inline FW_CPoint CDrawPart::GetDrawingSize() const
  309. {
  310.     return fDrawingSize;
  311. }
  312.  
  313. //----------------------------------------------------------------------------------------
  314. //    CDrawPart::GetPageSize
  315. //----------------------------------------------------------------------------------------
  316. inline FW_CPoint CDrawPart::GetPageSize() const
  317. {
  318.     return fPageSize;
  319. }
  320.  
  321. //----------------------------------------------------------------------------------------
  322. //    CDrawPart::IsAutoGridOn
  323. //----------------------------------------------------------------------------------------
  324. inline FW_Boolean CDrawPart::IsAutoGridOn() const
  325. {
  326.     return fAutoGrid;
  327. }
  328.  
  329. //----------------------------------------------------------------------------------------
  330. //    CDrawPart::GetPenSize
  331. //----------------------------------------------------------------------------------------
  332. inline FW_Fixed CDrawPart::GetPenSize() const
  333. {
  334.     return fCurrentPenSize;
  335. }
  336.  
  337. //----------------------------------------------------------------------------------------
  338. //    CDrawPart::GetRenderVerb
  339. //----------------------------------------------------------------------------------------
  340. inline unsigned short CDrawPart::GetRenderVerb() const
  341. {
  342.     return fRenderVerb;
  343. }
  344.  
  345. //----------------------------------------------------------------------------------------
  346. //    CDrawPart::GetTool
  347. //----------------------------------------------------------------------------------------
  348. inline unsigned short CDrawPart::GetTool() const
  349. {
  350.     return fTool;
  351. }
  352.  
  353. //----------------------------------------------------------------------------------------
  354. //    CDrawPart::GetMainPresentation
  355. //----------------------------------------------------------------------------------------
  356. inline FW_CPresentation* CDrawPart::GetMainPresentation() const
  357. {
  358.     return fMainPresentation;
  359. }
  360.  
  361. //----------------------------------------------------------------------------------------
  362. //    CDrawPart::GetMainPresentation
  363. //----------------------------------------------------------------------------------------
  364. inline FW_CPresentation* CDrawPart::GetPrintPresentation() const
  365. {
  366.     return fPrintPresentation;
  367. }
  368.  
  369. //----------------------------------------------------------------------------------------
  370. //    CDrawPart::GetPalettePresentation
  371. //----------------------------------------------------------------------------------------
  372. inline FW_CPresentation* CDrawPart::GetPalettePresentation() const
  373. {
  374.     return fPalettePresentation;
  375. }
  376.  
  377. //----------------------------------------------------------------------------------------
  378. //    CDrawPart::GetPatternPresentation
  379. //----------------------------------------------------------------------------------------
  380. inline FW_CPresentation* CDrawPart::GetPatternPresentation() const
  381. {
  382.     return fPatternPresentation;
  383. }
  384.  
  385. //----------------------------------------------------------------------------------------
  386. //    CDrawPart::GetToolPresentation
  387. //----------------------------------------------------------------------------------------
  388. inline FW_CPresentation* CDrawPart::GetToolPresentation() const
  389. {
  390.     return fToolPresentation;
  391. }
  392.  
  393. //----------------------------------------------------------------------------------------
  394. //    CDrawPart::GetFillColor
  395. //----------------------------------------------------------------------------------------
  396. inline void CDrawPart::GetFillColor(FW_CColor& color) const
  397. {
  398.     color = fFillColor;
  399. }
  400.  
  401. //----------------------------------------------------------------------------------------
  402. //    CDrawPart::GetFrameColor
  403. //----------------------------------------------------------------------------------------
  404. inline void CDrawPart::GetFrameColor(FW_CColor& color) const
  405. {
  406.     color = fFrameColor;
  407. }
  408.  
  409. //----------------------------------------------------------------------------------------
  410. //    CDrawPart::GetFillPattern
  411. //----------------------------------------------------------------------------------------
  412. inline FW_CPattern CDrawPart::GetFillPattern() const
  413. {
  414.     return fPatternTable[fFillPatIndex];
  415. }
  416.  
  417. //----------------------------------------------------------------------------------------
  418. //    CDrawPart::GetFramePattern
  419. //----------------------------------------------------------------------------------------
  420. inline FW_CPattern CDrawPart::GetFramePattern() const
  421. {
  422.     return fPatternTable[fFramePatIndex];
  423. }
  424.  
  425. //----------------------------------------------------------------------------------------
  426. //    CDrawPart::GetPattern
  427. //----------------------------------------------------------------------------------------
  428. inline FW_CPattern CDrawPart::GetPattern(short patIndex) const
  429. {
  430.     FW_ASSERT(patIndex>=0 && patIndex<12);
  431.     return fPatternTable[patIndex];
  432. }
  433.  
  434. #endif
  435.